<!-- S search -->
<app-search-bar
  [submitLoading]="tableParams.loading"
  [searchOptions]="searchOptions"
  labelFlex="80px"
  (onSearch)="queryResetData($event)"
  (onReset)="queryResetData($event)"
>
</app-search-bar>
<!-- E search -->

<nz-card class="m-t-2">
  <div class="pagination-wrap-position table-wrap">
    <nz-table
      #basicTable
      nzSize="small"
      nzShowSizeChanger
      nzShowQuickJumper
      nzOuterBordered
      [nzFrontPagination]="false"
      [nzLoadingDelay]="100"
      [nzLoading]="tableParams.loading"
      [nzData]="tableParams.tableData"
      [nzPageSizeOptions]="[5, 10, 20, 50, 100]"
      [nzTotal]="tableParams.total"
      [nzPageIndex]="tableParams.page"
      [nzPageSize]="tableParams.pageSize"
      [nzShowTotal]="totalTemplate"
      (nzPageIndexChange)="onPageIndexChange($event)"
      (nzPageSizeChange)="onPageSizeChange($event)"
    >
      <thead>
        <tr>
          <th nzAlign="center" nzWidth="200px">操作时间</th>
          <th nzAlign="center" nzWidth="200px">类型</th>
          <th nzAlign="center" nzWidth="200px">操作人</th>
          <th nzAlign="center" nzWidth="200px">数量</th>
          <th nzAlign="center">扫码结果</th>
        </tr>
      </thead>

      <tbody>
        <tr *ngFor="let data of basicTable.data; let index = index;">
          <!-- 操作时间 -->
          <td nzAlign="center">{{ data.operateTime || '-' }}</td>
          <!-- 类型 -->
          <td nzAlign="center">
            <span [ngStyle]="{'color': data.type === 1 ? '#67C23A' : '#F56C6C'}">
              {{ data.type === 1 ? '入库' : (data.type === 2 ? '出库' : '-') }}
            </span>
          </td>
          <!-- 操作人 -->
          <td nzAlign="center">{{ data.operator || '-' }}</td>
          <!-- 数量 -->
          <td nzAlign="center">{{ data.number || '0' }}</td>
          <!-- 扫码结果 -->
          <td nzAlign="center">
            <ng-container *ngIf="data.result; else elseTemplate">
              <ng-container *ngFor="let onum of data.resultArrs">
                <a
                  *ngIf="data.type === 1"
                  style="color: #1890ff"
                  class="m-r-8"
                  target="_blank"
                  routerLink="/aisi-recyc/loveOrderManage"
                  [queryParams]="{logisticsCode: onum}">
                  {{ onum }}
                </a>
                <a
                  *ngIf="data.type === 2"
                  style="color: #1890ff"
                  class="m-r-8"
                  target="_blank"
                  routerLink="/used-store/usedOutList"
                  [queryParams]="{logisticsCode: onum}">
                  {{ onum }}
                </a>
              </ng-container>
            </ng-container>
            <ng-template #elseTemplate>
              -
            </ng-template>
          </td>
        </tr>

        <tr *ngIf="tableParams.tableData.length">
          <td nzAlign="center" colSpan="3"><b>合计</b></td>
          <td nzAlign="center">
            <p><b>入库：{{ putOutObjs.in }}</b></p>
            <p><b>出库：{{ putOutObjs.out }}</b></p>
          </td>
          <td nzAlign="center">-</td>
        </tr>
      </tbody>
    </nz-table>

    <!-- 分页template -->
    <ng-template #totalTemplate let-total>共有 {{ total }} 条</ng-template>
  </div>
</nz-card>
